﻿// Deactivated for now. Seems not possible to leave title empty when saving an item because of the validation error caused.

//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Web;
//using Orchard.ContentManagement;
//using Orchard.Core.Title.Models;
//using Orchard.Localization;

//namespace Piedone.ContentTemplates.Services.TemplateLoaders
//{
//    public class TitleTemplateLoader : ITemplateLoader
//    {
//        private readonly ITemplateLoaderDescriptor _descriptor = new TemplateLoaderDescriptor("Title", new LocalizedString("Title"), new LocalizedString("Initializes the title from the template."));
//        public ITemplateLoaderDescriptor Descriptor { get { return _descriptor; } }

//        public bool CanHandle(IContent item)
//        {
//            return item.Has<TitlePart>();
//        }

//        public void LoadFromTemplate(IContent template, IContent item)
//        {
//            if (!CanHandle(template) || !CanHandle(item)) return;

//            item.As<TitlePart>().Title = template.As<TitlePart>().Title;
//        }
//    }
//}